<template>
  <div>
    <div style="height:600px;">
      <el-card
        v-for="o in this.Order"
        :key="o.m_Item7"
        class="box-card"
        style="margin-top:25px;"
        shadow="hover"
      >
        <div slot="header" class="clearfix">
          <h1>{{o.m_Item5}}</h1>
          <h5>订单号：{{o.m_Item7}}</h5>
          <el-popconfirm title="确认退票吗？" @onConfirm="Retick(o.m_Item7)">
            <el-button style="float: right; padding: 3px 0" type="text" slot="reference">退票</el-button>
          </el-popconfirm>
        </div>

        <div class="text item">
          <el-col :span="6">
            <img :src="o.m_Item4" style="height:150px;" />
          </el-col>
          <el-col :span="6">
            <p style="margin-top:45px;">开始时间：{{o.m_Item3}}</p>
            <p>影厅：{{o.m_Item6}}</p>
            <p>座位：{{o.m_Item1}}</p>
          </el-col>
          <el-col :span="6" style="text-align:center;line-height:150px;">￥{{o.m_Item2}}</el-col>
          <el-col
            :span="6"
            style="text-align:center;line-height:150px;"
            v-if="IsFinsh(o.m_Item3)"
          >已完成</el-col>
          <el-col
            :span="6"
            style="text-align:center;line-height:150px;"
            v-if="IsFinsh1(o.m_Item3)"
          >未完成</el-col>
        </div>
      </el-card>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      User: this.$cookies.get("User"),
      Order: [],
      NowTime: new Date()
    };
  },
  mounted() {},
  methods: {
    IsFinsh(STime) {
      if (new Date() > Date.parse(STime)) {
        return true;
      } else {
        return false;
      }
    },
    IsFinsh1(STime) {
      if (new Date() < Date.parse(STime)) {
        return true;
      } else {
        return false;
      }
    },
    async OrderInfo() {
      await this.Ajax.get(
        "api/Order/GetOrederByUserID?ID=" + this.User.UserID
      ).then(O => {
        console.log("21`");
        this.Order = O.data;
        console.log(O.data);
        this.tableData = O.data;
      });
    },
    Retick(id) {
      this.Ajax.get("api/Order/DeleteByID?ID=" + id).then(res => {
        if (res.data == 1) {
          this.$notify({
            title: "成功",
            message: "退票成功",
            type: "success"
          });
          setTimeout(function() {
            window.location.reload();
          }, 1000);
        } else if (res.data == 3) {
          this.$notify.error({
            title: "错误",
            message: "时间在一小时内，不能退款"
          });
        } else {
          this.$notify.error({
            title: "错误",
            message: "退票失败"
          });
        }
      });
    }
  },
  created() {
    this.OrderInfo();
    console.log(this.NowTime > Date.parse("2020-06-20T13:00:00"));
  }
};
</script>
